//============================================================
// Producnt name:		Wz
// Version: 			1.0
// Coded by:			Wz (13066628480@163.com)
// Auto generated at: 	2016/10/9 10:22:03
//============================================================

using System;
using System.Collections.Generic;
using System.Text;
using Cloud.Model;
using System.Data.SqlClient;
using System.Data;
namespace Cloud.DAL
{
	public static class Problem_historicService
	{
		#region SqlCommandText
		private const string Save_CommandText = "insert into Problem_historic values(@idopen,@times,@sections,@title,@evente,@slr,@blyj,@timese,@hfnr,@zbdw,@zbhfnr,@zbtsrfk,@zbbz,@fkhfnr,@fkfkqk,@fkyfkcc,@shhfnr,@shzt,@shtsrfk,@bhdqdw,@bhz,@dbzt,@item1,@item2,@item3,@item4,@item5,@item6)";
		private const string Update_CommandText = "Update Problem_historic set idopen = @idopen,times = @times,sections = @sections,title = @title,evente = @evente,slr = @slr,blyj = @blyj,timese = @timese,hfnr = @hfnr,zbdw = @zbdw,zbhfnr = @zbhfnr,zbtsrfk = @zbtsrfk,zbbz = @zbbz,fkhfnr = @fkhfnr,fkfkqk = @fkfkqk,fkyfkcc = @fkyfkcc,shhfnr = @shhfnr,shzt = @shzt,shtsrfk = @shtsrfk,bhdqdw = @bhdqdw,bhz = @bhz,dbzt = @dbzt,item1 = @item1,item2 = @item2,item3 = @item3,item4 = @item4,item5 = @item5,item6 = @item6 where id = @id";
		private const string Delete_CommandText = "delete from Problem_historic where id = @id";
		private const string FindAll_CommandText = "select * from Problem_historic";
		private const string FindById_CommandText = "select * from Problem_historic where id=@id";
		#endregion
		
		#region ??
		
		#endregion
		
		#region ??
		
		#endregion
		
		#region Save
		public static int Save(Problem_historic problem_historic)
		{
			SqlParameter[] pars = new SqlParameter[]{
				new SqlParameter("@idopen",SqlDbType.VarChar),
				new SqlParameter("@times",SqlDbType.DateTime),
				new SqlParameter("@sections",SqlDbType.VarChar),
				new SqlParameter("@title",SqlDbType.VarChar),
				new SqlParameter("@evente",SqlDbType.Int),
				new SqlParameter("@slr",SqlDbType.VarChar),
				new SqlParameter("@blyj",SqlDbType.VarChar),
				new SqlParameter("@timese",SqlDbType.DateTime),
				new SqlParameter("@hfnr",SqlDbType.VarChar),
				new SqlParameter("@zbdw",SqlDbType.VarChar),
				new SqlParameter("@zbhfnr",SqlDbType.VarChar),
				new SqlParameter("@zbtsrfk",SqlDbType.VarChar),
				new SqlParameter("@zbbz",SqlDbType.VarChar),
				new SqlParameter("@fkhfnr",SqlDbType.VarChar),
				new SqlParameter("@fkfkqk",SqlDbType.VarChar),
				new SqlParameter("@fkyfkcc",SqlDbType.VarChar),
				new SqlParameter("@shhfnr",SqlDbType.VarChar),
				new SqlParameter("@shzt",SqlDbType.VarChar),
				new SqlParameter("@shtsrfk",SqlDbType.VarChar),
				new SqlParameter("@bhdqdw",SqlDbType.VarChar),
				new SqlParameter("@bhz",SqlDbType.VarChar),
				new SqlParameter("@dbzt",SqlDbType.VarChar),
				new SqlParameter("@item1",SqlDbType.Int),
				new SqlParameter("@item2",SqlDbType.Int),
				new SqlParameter("@item3",SqlDbType.VarChar),
				new SqlParameter("@item4",SqlDbType.VarChar),
				new SqlParameter("@item5",SqlDbType.VarChar),
				new SqlParameter("@item6",SqlDbType.VarChar)
				};
			pars[0].Value=problem_historic.Idopen;
			pars[1].Value=problem_historic.Times;
			pars[2].Value=problem_historic.Sections;
			pars[3].Value=problem_historic.Title;
			pars[4].Value=problem_historic.Evente;
			pars[5].Value=problem_historic.Slr;
			pars[6].Value=problem_historic.Blyj;
			pars[7].Value=problem_historic.Timese;
			pars[8].Value=problem_historic.Hfnr;
			pars[9].Value=problem_historic.Zbdw;
			pars[10].Value=problem_historic.Zbhfnr;
			pars[11].Value=problem_historic.Zbtsrfk;
			pars[12].Value=problem_historic.Zbbz;
			pars[13].Value=problem_historic.Fkhfnr;
			pars[14].Value=problem_historic.Fkfkqk;
			pars[15].Value=problem_historic.Fkyfkcc;
			pars[16].Value=problem_historic.Shhfnr;
			pars[17].Value=problem_historic.Shzt;
			pars[18].Value=problem_historic.Shtsrfk;
			pars[19].Value=problem_historic.Bhdqdw;
			pars[20].Value=problem_historic.Bhz;
			pars[21].Value=problem_historic.Dbzt;
			pars[22].Value=problem_historic.Item1;
			pars[23].Value=problem_historic.Item2;
			pars[24].Value=problem_historic.Item3;
			pars[25].Value=problem_historic.Item4;
			pars[26].Value=problem_historic.Item5;
			pars[27].Value=problem_historic.Item6;
	
			return DBHelper.ExecuteNonQuery(Save_CommandText,CommandType.Text,pars);
		}
		#endregion
		
		#region Update
		public static int Update(Problem_historic problem_historic)
		{
			SqlParameter[] pars = new SqlParameter[]{
				new SqlParameter("@id",SqlDbType.Int),
				new SqlParameter("@idopen",SqlDbType.VarChar),
				new SqlParameter("@times",SqlDbType.DateTime),
				new SqlParameter("@sections",SqlDbType.VarChar),
				new SqlParameter("@title",SqlDbType.VarChar),
				new SqlParameter("@evente",SqlDbType.Int),
				new SqlParameter("@slr",SqlDbType.VarChar),
				new SqlParameter("@blyj",SqlDbType.VarChar),
				new SqlParameter("@timese",SqlDbType.DateTime),
				new SqlParameter("@hfnr",SqlDbType.VarChar),
				new SqlParameter("@zbdw",SqlDbType.VarChar),
				new SqlParameter("@zbhfnr",SqlDbType.VarChar),
				new SqlParameter("@zbtsrfk",SqlDbType.VarChar),
				new SqlParameter("@zbbz",SqlDbType.VarChar),
				new SqlParameter("@fkhfnr",SqlDbType.VarChar),
				new SqlParameter("@fkfkqk",SqlDbType.VarChar),
				new SqlParameter("@fkyfkcc",SqlDbType.VarChar),
				new SqlParameter("@shhfnr",SqlDbType.VarChar),
				new SqlParameter("@shzt",SqlDbType.VarChar),
				new SqlParameter("@shtsrfk",SqlDbType.VarChar),
				new SqlParameter("@bhdqdw",SqlDbType.VarChar),
				new SqlParameter("@bhz",SqlDbType.VarChar),
				new SqlParameter("@dbzt",SqlDbType.VarChar),
				new SqlParameter("@item1",SqlDbType.Int),
				new SqlParameter("@item2",SqlDbType.Int),
				new SqlParameter("@item3",SqlDbType.VarChar),
				new SqlParameter("@item4",SqlDbType.VarChar),
				new SqlParameter("@item5",SqlDbType.VarChar),
				new SqlParameter("@item6",SqlDbType.VarChar)
				};
			pars[0].Value=problem_historic.Id;
			pars[1].Value=problem_historic.Idopen;
			pars[2].Value=problem_historic.Times;
			pars[3].Value=problem_historic.Sections;
			pars[4].Value=problem_historic.Title;
			pars[5].Value=problem_historic.Evente;
			pars[6].Value=problem_historic.Slr;
			pars[7].Value=problem_historic.Blyj;
			pars[8].Value=problem_historic.Timese;
			pars[9].Value=problem_historic.Hfnr;
			pars[10].Value=problem_historic.Zbdw;
			pars[11].Value=problem_historic.Zbhfnr;
			pars[12].Value=problem_historic.Zbtsrfk;
			pars[13].Value=problem_historic.Zbbz;
			pars[14].Value=problem_historic.Fkhfnr;
			pars[15].Value=problem_historic.Fkfkqk;
			pars[16].Value=problem_historic.Fkyfkcc;
			pars[17].Value=problem_historic.Shhfnr;
			pars[18].Value=problem_historic.Shzt;
			pars[19].Value=problem_historic.Shtsrfk;
			pars[20].Value=problem_historic.Bhdqdw;
			pars[21].Value=problem_historic.Bhz;
			pars[22].Value=problem_historic.Dbzt;
			pars[23].Value=problem_historic.Item1;
			pars[24].Value=problem_historic.Item2;
			pars[25].Value=problem_historic.Item3;
			pars[26].Value=problem_historic.Item4;
			pars[27].Value=problem_historic.Item5;
			pars[28].Value=problem_historic.Item6;
	
			return DBHelper.ExecuteNonQuery(Update_CommandText,CommandType.Text,pars);
		}
		#endregion
		
		#region Delete
		public static int Delete(Problem_historic problem_historic)
		{
			SqlParameter[] pars = new SqlParameter[]{
				new SqlParameter("@id",SqlDbType.Int)
				};
			pars[0].Value=problem_historic.Id;
	
			return DBHelper.ExecuteNonQuery(Delete_CommandText,CommandType.Text,pars);
		}
		#endregion
		
		#region FindAll
		public static IList<Problem_historic> FindAll()
		{
			return CommonQuery(FindAll_CommandText,CommandType.Text,null);
		}
		#endregion
		
		#region FindById
		public static Problem_historic FindById(Int32 id)
		{
			SqlParameter[] pars = new SqlParameter[]{
				new SqlParameter("@id",SqlDbType.Int)
			};	
			pars[0].Value = id;
			IList<Problem_historic> list = CommonQuery(FindById_CommandText,CommandType.Text,pars);
			return list.Count > 0 ? list[0] : null;
		}
		#endregion
		
		#region ??
		
		#endregion
		
		#region ??
		
		#endregion
		
		#region CommonQuery
		private static IList<Problem_historic> CommonQuery(string commandText, CommandType cmdType, SqlParameter[] pars)
		{
			IList<Problem_historic> list = new List<Problem_historic>();
			Problem_historic problem_historic = null;
			
			using (SqlDataReader reader = DBHelper.ExecuteQuery(commandText,cmdType,pars))
           	{
				while(reader.Read())
				{
					problem_historic = new Problem_historic();
                    if (reader["id"]==null)
                    {
                        problem_historic.Id = 0;
                    }
                    else
                    {
                        problem_historic.Id = Convert.ToInt32(reader["id"]);
                    }

                    if (reader["idopen"]==null)
                    {
                        problem_historic.Idopen = "";
                    }
                    else
                    {
                        problem_historic.Idopen = Convert.ToString(reader["idopen"]);
                    }

                    if (reader["times"]==null)
                    {
                        problem_historic.Times = new DateTime(1900, 01, 01, 00, 00, 00);
                    }
                    else
                    {
                        problem_historic.Times = Convert.ToDateTime(reader["times"]);
                    }

                    if (reader["sections"]==null)
                    {
                        problem_historic.Sections = "";
                    }
                    else
                    {
                        problem_historic.Sections = Convert.ToString(reader["sections"]);
                    }

                    if (reader["title"]==null)
                    {
                        problem_historic.Title = "";
                    }
                    else
                    {
                        problem_historic.Title = Convert.ToString(reader["title"]);
                    }

                    if (reader["evente"]==null)
                    {
                        problem_historic.Evente = 0;
                    }
                    else
                    {
                        problem_historic.Evente = Convert.ToInt32(reader["evente"]);
                    }

                    if (reader["slr"]==null)
                    {
                        problem_historic.Slr = "";
                    }
                    else
                    {
                        problem_historic.Slr = Convert.ToString(reader["slr"]);
                    }

                    if (reader["blyj"]==null)
                    {
                        problem_historic.Blyj = "";
                    }
                    else
                    {
                        problem_historic.Blyj = Convert.ToString(reader["blyj"]);
                    }

                    if (reader["timese"]==null)
                    {
                        problem_historic.Timese = new DateTime(1900, 01, 01, 00, 00, 00);
                    }
                    else
                    {
                        problem_historic.Timese = Convert.ToDateTime(reader["timese"]);
                    }

                    if (reader["hfnr"]==null)
                    {
                        problem_historic.Hfnr = "";
                    }
                    else
                    {
                        problem_historic.Hfnr = Convert.ToString(reader["hfnr"]);
                    }

                    if (reader["zbdw"]==null)
                    {
                        problem_historic.Zbdw = "";
                    }
                    else
                    {
                        problem_historic.Zbdw = Convert.ToString(reader["zbdw"]);
                    }

                    if (reader["zbhfnr"]==null)
                    {
                        problem_historic.Zbhfnr = "";
                    }
                    else
                    {
                        problem_historic.Zbhfnr = Convert.ToString(reader["zbhfnr"]);
                    }

                    if (reader["zbtsrfk"]==null)
                    {
                        problem_historic.Zbtsrfk = "";
                    }
                    else
                    {
                        problem_historic.Zbtsrfk = Convert.ToString(reader["zbtsrfk"]);
                    }

                    if (reader["zbbz"]==null)
                    {
                        problem_historic.Zbbz = "";
                    }
                    else
                    {
                        problem_historic.Zbbz = Convert.ToString(reader["zbbz"]);
                    }

                    if (reader["fkhfnr"]==null)
                    {
                        problem_historic.Fkhfnr = "";
                    }
                    else
                    {
                        problem_historic.Fkhfnr = Convert.ToString(reader["fkhfnr"]);
                    }

                    if (reader["fkfkqk"] == null)
                    {
                        problem_historic.Fkfkqk = "";
                    }
                    else
                    {
                        problem_historic.Fkfkqk = Convert.ToString(reader["fkfkqk"]);
                    }

                    if (reader["fkyfkcc"]==null)
                    {
                        problem_historic.Fkyfkcc = "";
                    }
                    else
                    {
                        problem_historic.Fkyfkcc = Convert.ToString(reader["fkyfkcc"]);
                    }

                    if (reader["shhfnr"]==null)
                    {
                        problem_historic.Shhfnr = "";
                    }
                    else
                    {
                        problem_historic.Shhfnr = Convert.ToString(reader["shhfnr"]);
                    }

                    if (reader["shzt"]==null)
                    {
                        problem_historic.Shzt = "";
                    }
                    else
                    {
                        problem_historic.Shzt = Convert.ToString(reader["shzt"]);
                    }

                    if (reader["shtsrfk"]==null)
                    {
                        problem_historic.Shtsrfk = "";
                    }
                    else
                    {
                        problem_historic.Shtsrfk = Convert.ToString(reader["shtsrfk"]);
                    }

                    if (reader["bhdqdw"]==null)
                    {
                        problem_historic.Bhdqdw = "";
                    }
                    else
                    {
                        problem_historic.Bhdqdw = Convert.ToString(reader["bhdqdw"]);
                    }

                    if (reader["bhz"]==null)
                    {
                        problem_historic.Bhz = "";
                    }
                    else
                    {
                        problem_historic.Bhz = Convert.ToString(reader["bhz"]);
                    }

                    if (reader["dbzt"]==null)
                    {
                        problem_historic.Dbzt = "";
                    }
                    else
                    {
                        problem_historic.Dbzt = Convert.ToString(reader["dbzt"]);
                    }

                    if (reader["item1"]==null)
                    {
                        problem_historic.Item1 = 0;
                    }
                    else
                    {
                        problem_historic.Item1 = Convert.ToInt32(reader["item1"]);
                    }

                    if (reader["item2"]==null)
                    {
                        problem_historic.Item2 = 0;
                    }
                    else
                    {
                        problem_historic.Item2 = Convert.ToInt32(reader["item2"]);
                    }

                    if (reader["item3"]==null)
                    {
                        problem_historic.Item3 = "";
                    }
                    else
                    {
                        problem_historic.Item3 = Convert.ToString(reader["item3"]);
                    }

                    if (reader["item4"]==null)
                    {
                        problem_historic.Item4 = "";
                    }
                    else
                    {
                        problem_historic.Item4 = Convert.ToString(reader["item4"]);
                    }

                    if (reader["item5"]==null)
                    {
                        problem_historic.Item5 = "";
                    }
                    else
                    {
                        problem_historic.Item5 = Convert.ToString(reader["item5"]);
                    }

                    if (reader["item6"]==null)
                    {
                        problem_historic.Item6 = "";
                    }
                    else
                    {
                        problem_historic.Item6 = Convert.ToString(reader["item6"]);
                    }
					
					
					list.Add(problem_historic);
				}
            }
            return list;
		}
		#endregion
		
		#region ??
		
		#endregion
		
		#region ??
		
		#endregion
	}
}



